package part18;

import java.io.File;

/**
 * @author wcj
 * @Date 2021/6/2 16:41
 * @Version 1.0
 */
public class Part186 {

    /**
     * File类除了表示文件或者目录，还可以使用这个类来创建文件或者目录，并且读取文件或者目录的特性，也可以进行删除等操作
     */
    private static void usage() {
        System.err.println(
                "Usage:MakeDirectories path1...\n" +
                        "Creates each path\n" +
                        "Usage:MakeDirectories -d path1...\n" +
                        "Deletes each path\n" +
                        "Usage:MakeDirectories -r path1 path2\n" +
                        "Renames from path1 to path2\n"
        );
        System.exit(1);
    }

    private static void fileData(File f) {
        System.out.println(
                "Absolute path:" + f.getAbsolutePath() +
                        "\n Can read:" + f.canRead() +
                        "\n Can write:" + f.canWrite() +
                        "\n getName:" + f.getName() +
                        "\n getParent:" + f.getParent() +
                        "\n getPath:" + f.getParent() +
                        "\n length:" + f.length() +
                        "\n lastModified:" + f.lastModified()
        );
        if (f.isFile()) {
            System.out.println("it's a file");
        } else if (f.isDirectory()) {
            System.out.println("it's a directory");
        }
    }

    public static void main(String[] args) {
        String path = "./hhh";
        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }
        fileData(file);
    }
}
